package example.org;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ShareImage extends Activity implements OnClickListener {
	private Button mSelectPicture;
	private static int PICK_IMAGE = 1;
	// private Cursor mCursor;
	// ArrayList array;
	int mIndex = 0;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shareimage);
		mSelectPicture = (Button) findViewById(R.id.button1);
		mSelectPicture.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v == mSelectPicture) {
			Intent intent = new Intent();
			intent.setType("image/*");
			intent.setAction(Intent.ACTION_GET_CONTENT);
			startActivityForResult(
					Intent.createChooser(intent, "Hayooo Pilih Mana?"),
					PICK_IMAGE);

			// cupu
			// Intent choosePictureIntent = new Intent(
			// Intent.ACTION_PICK,
			// android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
			// startActivityForResult(choosePictureIntent, 0);
		}
	}

	protected void onActivityResult(int requestCode, int resultCode,
			Intent intent) {
		super.onActivityResult(requestCode, resultCode, intent);
		if (resultCode == RESULT_OK) {
			Uri imageFileUri = intent.getData();
			Intent i = new Intent();
			i.putExtra("gambar", imageFileUri + "");
			startActivity(i);
		}
	}
}
